<?php
class UsersController extends Zend_Controller_Action
{
	
	
	function init() 
	{
		// Initialize the view
		$this->initView();
		// Store the base url for the current request in the view
		$this->view->baseUrl = $this->_request->getBaseUrl();	
	}
	
	
	function indexAction()
	{
		$users = new Users();
		$this->view->users = $users->fetchAll();
		

		$user = $this->view->users->getRow(1);
		$this->view->chars = $user->findCharacters();

	}

	function adminDeleteAction()
	{
		$id = (int)$this->_request->getParam('id');
	}
	
	/*function deleteAction()
	{

	}*/
	

	
	function createAction()
	{
		$this->view->message = '';		
		if ($this->_request->isPost()) {			
		
			$users = new Users();
		
			$name = $this->_request->getParam('username');
			$nickname = $this->_request->getParam('nickname');
			$password = sha1($this->_request->getParam('password'));
		
			$data = array(
				'username' 	=> $name,
				'nickname'	=> $nickname,
				'password'	=> $password
			);
			$users->insert($data);	
		}
		$this->view->title = "Create User";	
	}

}
?>